package com.yizhe.controller;

import com.alibaba.fastjson.JSONObject;
import com.yizhe.domain.vo.TbkQueryVO;
import com.yizhe.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 
 * 
 * @author fangchao
 * 
 */
@Controller
@RequestMapping("/product")
public class ProductController {

	@Resource
	private ProductService productService;

	@RequestMapping("cloudProductListPage")
	public String cloudProductListPage() {
		return "cloudProductList";
	}
	
	@RequestMapping("baseSettingPage")
	public String baseSettingPage() {
		return "baseSetting";
	}
	
	@RequestMapping("createItemPage")
	public String createItemPage() {
		return "createItem";
	}
	
	@RequestMapping("myItemPage")
	public String myItemPage() {
		return "myItem";
	}
	
	@RequestMapping("wechatRobotPage")
	public String wechatRobotPage() {
		return "wechatRobot";
	}
	
	@RequestMapping("payMoneyPage")
	public String payMoneyPage() {
		return "payMoney";
	}
	
	@RequestMapping("cashMoneyPage")
	public String cashMoneyPage() {
		return "cashMoney";
	}
	
	@RequestMapping("moneyRecodePage")
	public String moneyRecodePage() {
		return "moneyRecode";
	}
	
	@RequestMapping("activationPage")
	public String activationPage() {
		return "activation";
	}
	
	@RequestMapping("cleanPage")
	public String cleanPage() {
		return "clean";
	}
	
	/**
	 * 请求云产品库数据
	 * @param model
	 * @param user
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("cloudProductList")
	@ResponseBody
	public Map<String, Object> cloudProductList(@ModelAttribute TbkQueryVO tbkQueryVO,HttpServletRequest request) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			JSONObject jsonObject = productService.getTbkItems(tbkQueryVO);
			map.put("code", 200);
			map.put("data", jsonObject);
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", 0);
			map.put("data", "请求失败，请联系管理员");
		}
		return map;
	}

}
